import 'package:flutter/material.dart';

import '../../utils/easy_throttle.dart';

class AppGesture extends InkWell {
  AppGesture._init({
    super.key,
    super.child,
    GestureTapCallback? onTap,
    super.onDoubleTap,
    super.onLongPress,
    super.onTapDown,
    super.onTapUp,
    super.onTapCancel,
    super.onHighlightChanged,
    super.onHover,
    super.mouseCursor,
    super.focusColor,
    super.hoverColor,
    super.highlightColor = Colors.transparent,
    super.overlayColor,
    super.splashColor = Colors.transparent,
    super.splashFactory,
    super.radius,
    super.borderRadius,
    super.customBorder,
    bool? enableFeedback = true,
    super.excludeFromSemantics,
    super.focusNode,
    super.canRequestFocus,
    super.onFocusChange,
    super.autofocus,
    super.statesController,
    bool throttle = true,
    Duration? throttleDuration = const Duration(milliseconds: 500),
  }) : super(onTap: throttle ? (onTap == null ? null : EasyThrottle.tapThrottle(onTap, duration: throttleDuration)) : onTap);
  factory AppGesture({
    Key? key,
    Widget? child,
    EdgeInsetsGeometry? padding,
    GestureTapCallback? onTap,
    GestureTapCallback? onDoubleTap,
    GestureTapCallback? onLongPress,
    GestureTapDownCallback? onTapDown,
    GestureTapUpCallback? onTapUp,
    GestureTapCancelCallback? onTapCancel,
    ValueChanged<bool>? onHighlightChanged,
    ValueChanged<bool>? onHover,
    MouseCursor? mouseCursor,
    Color? focusColor,
    Color? hoverColor,
    Color? highlightColor = Colors.transparent,
    WidgetStateProperty<Color?>? overlayColor,
    Color? splashColor = Colors.transparent,
    InteractiveInkFeatureFactory? splashFactory,
    double? radius,
    BorderRadius? borderRadius,
    ShapeBorder? customBorder,
    bool? enableFeedback = true,
    bool excludeFromSemantics = false,
    FocusNode? focusNode,
    bool canRequestFocus = true,
    ValueChanged<bool>? onFocusChange,
    bool autofocus = false,
    WidgetStatesController? statesController,
    bool throttle = true,
    Duration? throttleDuration = const Duration(milliseconds: 500),
  }) {
    if (padding != null) {
      child = Padding(padding: padding, child: child);
    }
    return AppGesture._init(
      key: key,
      onTap: onTap,
      onDoubleTap: onDoubleTap,
      onLongPress: onLongPress,
      onTapDown: onTapDown,
      onTapUp: onTapUp,
      onTapCancel: onTapCancel,
      onHighlightChanged: onHighlightChanged,
      onHover: onHover,
      mouseCursor: mouseCursor,
      focusColor: focusColor,
      hoverColor: hoverColor,
      highlightColor: highlightColor,
      overlayColor: overlayColor,
      splashColor: splashColor,
      splashFactory: splashFactory,
      radius: radius,
      borderRadius: borderRadius,
      customBorder: customBorder,
      enableFeedback: enableFeedback,
      excludeFromSemantics: excludeFromSemantics,
      focusNode: focusNode,
      canRequestFocus: canRequestFocus,
      onFocusChange: onFocusChange,
      autofocus: autofocus,
      statesController: statesController,
      throttle: throttle,
      throttleDuration: throttleDuration,
      child: child,
    );
  }
}
